package lxs.tool.liberator.common.utils;

import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDDocumentInformation;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.PDPageContentStream;
import org.apache.pdfbox.pdmodel.font.PDType1Font;

import java.io.IOException;
import java.util.Calendar;
import java.util.GregorianCalendar;

public class PdfMan {
    private void a(String project) throws IOException {
        PDDocument document = new PDDocument();
        PDPage page = new PDPage();
        document.addPage(page);
        PDDocumentInformation pdd = document.getDocumentInformation();
        pdd.setAuthor("Liberator");
        pdd.setTitle("接口文档");
        pdd.setCreator("PDF Examples");
        pdd.setSubject(project+"api文档");
        Calendar date = new GregorianCalendar();
        pdd.setCreationDate(date);
        pdd.setModificationDate(date);
        PDPageContentStream contentStream = new PDPageContentStream(document, page);
        contentStream.beginText();

        contentStream.setFont(PDType1Font.HELVETICA_BOLD, 14);

        //Setting the position for the line
        contentStream.newLineAtOffset(25, 500);

        String text = "This is the sample document and we are adding content to it. - By yiibai.com";

        //Adding text in the form of string
        contentStream.showText(text);

        //Ending the content stream
        contentStream.endText();



    }
}
